# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=soundtouch
pkgbase="mingw-w64-${_realname}"
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.3.2
pkgrel=1
pkgdesc="An audio processing library (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url="https://www.surina.net/soundtouch/"
license=("LGPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-cc")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
options=('strip' 'staticlibs')
source=(https://www.surina.net/${_realname}/${_realname}-${pkgver}.tar.gz
        0001-no-undefined-on.mingw.patch
        0003-fix-docdir.mingw.patch)
sha256sums=('3bde8ddbbc3661f04e151f72cf21ca9d8f8c88e265833b65935b8962d12d6b08'
            '76b3041e952675e56138461c5fa8a5abacac31380ce90b27038d0deac46f91be'
            '2cd136046831f3ad9a2e37c0afe3ecd9f25ce27f5dbf4ee8b23b862a96e76cd5')

prepare() {
  cd "${srcdir}/${_realname}"
  sed -i 's/AM_CONFIG_HEADER/AC_CONFIG_HEADER/' configure.ac
  patch -p1 -i ${srcdir}/0001-no-undefined-on.mingw.patch
  patch -p1 -i ${srcdir}/0003-fix-docdir.mingw.patch

  ./bootstrap
}

build() {
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  ../${_realname}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-static \
    --enable-shared

  make
}

package() {
  cd build-${MSYSTEM}
  make DESTDIR="${pkgdir}" install
  install -Dm644 "${srcdir}/${_realname}/COPYING.TXT" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING.TXT"
}
